$(function(){
	//导航管理
	var a;
	var arr, arrUrl;
	var navTitle = {};
	var navChilden ={};
	var leftNav = {};
	
	$('.ncsc-nav > dl').each(function(i){
		
		if( i == 0 ) return;
		
		a = 'a'+ i;
		
		navChilden[a] = [];
		navTitle[a] = $(this).children('dt').text();
		
		
		$(this).find('li').each(function(y){
			
			arr = $(this).find('a').text()
			
			arrUrl = $(this).find('a').attr('href')
			
			navChilden[a].push([arr,arrUrl])
			
		})
	})
		
	$.each(navChilden,function(k){
		
		var str = '';
		
		$.each(navChilden[k],function(v){
			
			str+='<dd><i></i><a href='+navChilden[k][v][1]+'>'+navChilden[k][v][0]+'</a></dd>';
			
		})
		
		$('#quicklink_list').append(
			
				'<dl><dt>'+navTitle[k]+'</dt>'+str+'</dl>'
				
			).find('i').attr(
				
					{'class':'icon-check','title':'添加为常用功能菜单'}
					
				)
	

	})
//添加侧边快捷导航
	$('#quicklink_list').find('i').click(function(){
		
			var selected = $(this).parent('dd').attr('class');
			var aTxt,aHref;
			var liNav="<div class=add-quickmenu><a href=javascript:void(0);><i class=icon-plus></i>添加常用功能菜单</a></div>";
			
			aTxt = $(this).siblings('a').text();
			aHref = $(this).siblings('a').attr('href');
			if (!selected) {
				
				$(this).parent('dd').attr('class','selected');
				
				leftNav[aTxt] = aHref;
				console.log(leftNav)
				
			} else{
				
				$(this).parent('dd').attr('class','');
				delete leftNav[aTxt];
				console.log(leftNav)
				
			}
			$.each(leftNav, function(k,v) {
				
				liNav+='<li><a href'+ v +'>' + k + '</a></li>'
				$('#seller_center_left_menu').html(liNav)
				
			});
			
		})
	
	
	
})